Tmp=$HOME/tmp/bic/tmp
Backup=$HOME/opt/tmp/backup
Safe=$HOME/tmp/bic/safe
Vars=$Tmp/vars.txt
Profile=$Tmp/profile.txt
Debug="$HOME/opt/gawk/bin/pgawk --profile=$Profile --dump-variables=$Vars"
. ../etc/dotprofile $PWD

trap "echo -n 'Tidying up ...' ; rm -rf $Tmp; echo 'Bye!'; exit" 0 2 3 15 

misc()    { $Awk -f misc.awk --source 'BEGIN{'"$*"'}'; }
help()    { info -d $HOME/opt/gawk/share/info gawk; }
run()     { cd $Bic
            if   [ -f "lib/${1}Test.awk" ]
            then $Debug -f ${1}Test.awk; vars >&2;
            else . lib/${1}Test.sh;  fi | cat -n | tee $Tmp/$1.out
          }
cache()   { run $1; cp $Tmp/$1.out lib/${1}Test.out;  }
ok()      { run $1 > /dev/null; same $1 "lib/${1}Test.out" $Tmp/$1.out; }
same()    { if diff -s $2 $3 > /dev/null
            then echo "$1 passed"
            else echo "$1 failed"; fi
          } 
profile() { cat $Profile | sed '1d' ; }
vars()    { cat $Vars| egrep -v '^[A-Z]+:'| sed 's/^/rogue? /'; }
prep()    { echo "Preping..."; cd $Bic; . bic.sh; }
exists()  { [ ! -d "$1"  ] && mkdir -p "$1"; }

if   [ ! -x "$Awk" ]  
then echo "missing: gawk"
else 
	exists $Tmp
	exists $Safe
	exists $Backup
	. lib/tools.sh
	. demos.sh
	echo "BIC: (c) 2011 by Tim Menzies "
	PS1="BIC> "
fi
